<?php
	if (file_exists('php/user.php'))	require_once 'php/user.php';
	else 	if (file_exists('../user.php'))	require_once '../user.php';
	function curPageURL() {
		$pageURL = 'http';
		if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80") {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}
		return $pageURL;
	}
	session_start();
	if (isset($_SESSION['username'])){
		$login = true;
		$path = 'users/'.$_SESSION['username'].'/';
	}else{
		$login = false;
		header("Location: ".$CFG->url."home.php");
	}
	$URL = curPageURL();
	$length = strlen($URL);
	$j = -1;
	for ($i=0; $i<$length && ($j == -1); ++$i)
		if ($URL[$i] == '?')
			$j = $i+1;
	if ($j != -1)
		$username = substr($URL, $j);
	else
		$username = '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style/wall.css" />
<link rel="stylesheet" type="text/css" href="style/footoo.css" />
<link rel="stylesheet" type="text/css" href="style/ftheader.css" />
<link rel="stylesheet" type="text/css" href="style/ftfooter.css" />
<link rel="stylesheet" type="text/css" href="style/ftcommoncontent.css" />
<script type="text/javascript" src="script/search.js"></script> 
<script type="text/javascript" src="script/visopt.js"></script> 
<script type="text/javascript" src="script/ajax.js"></script>
<script type="text/javascript">
	setInterval("headerChange();",1000);
	setInterval("NotifCheck();",1000);
</script>
<title>Foo-Too Wall</title>
</head>

<body>
    <div id="headerwrapper">
		<div id = "headerbgfx"></div>
        <div id="footooheader">
        	<div id="footoologo">
            	<a href="#"></a>
            </div>
            <div id="logprofpicarea">
            <div id="profpicarea">
            <?php require 'php/viewer/header.php'; ?>
            </div>
            </div>
        </div>
        <div id="footoomenu">
            <ul>
				<?php
					if ($login)
					{
					    echo '<li><a href="home.php">Home</a></li>';
						echo '<li><a href="profile.php?'.$_SESSION['username'].'">Profile</a></li>';
						echo '<li><a class="current" href="wall.php?'.$_SESSION['username'].'">Wall</a>';
						echo '</li><li><a href="fts.php">Photos</a>';
						echo '</li><li><a href="message.php?un='.$_SESSION['username'].'">Message</a></li>';
					}
					else{
					    echo '<li><a href="" class="current">Welcome..</a></li>';
					}
				?>
            </ul>
        </div>
    </div>
    <div id="headermirror">
    	<div id="notifbutton">
        	<a style="color:#CCC" href="javascript:void();" onclick="getAllNotif();show('notification');">You have 0 new notification(s).</a>
        </div>
        <div id="notification">
            <div class="x" onclick="hide('notification');"></div>
            Notification:<br/><br/>
            <div id="listnotif">
                Empty.
            </div><br/><br/>
            <a id="morenotif" href="javascript:void();" onclick="getNotif(1);">See More...</a>
        </div>
    
    	<div id="searchbox">
            <form action="search.php" method="post">
            	<select class="searchselect" name="tipe">
                	<option value="user">User</option>
                	<option value="photo">Photo</option>
                </select>
                <div class="searchbutton">
                    <input id="searchbutton" type="submit" value="" />
                </div>
                <div class="searchtext">
                <input id="searchtext" class="searchtext" type="text" name="searchtext" value="search" onfocus="filledTrue(this.id, 'search')" onblur="filledFalse(this.id, 'search')" />
            	</div>
            </form>		
        </div>
	</div>
	<?php
		require_once 'php\database.php';
	?>
    <div id="contentwrapper">
    	<div id="contento">
	<?php
		$hasil = database::query("SELECT * FROM User WHERE username = '".$username."'");
		if (mysql_num_rows($hasil)>0)
		{
			$namafile = photo::getProfPicPath($username);
	?>
			<div class="detailleft" style="min-width:300px;display:block;height:inherit;text-align:center">
            	<img style="width:280px;margin:0px auto;" src="<?php echo $namafile;?>"/>
                <br style="clear:both"/><br/>
                <a class="unameh1" href="profile.php?un="<?php echo $username;?>><?php echo user::getName($username);?></a>
            </div>
			<div class="detailbigright" style="width:550px;">
          	<?php
			if (user::checkHakAksesWall($_SESSION['username'], $username))
			{
			?>
            <form action="php/posting.php" method="post" name="postingan">
				<table>
                <tr>
                    <td rowspan = 2>
                    </td><td><textarea cols = 62 rows = 2 id ="postingan" name="postingan"></textarea></td>
				</tr><tr>
                    <td align="right"><div class="button180" onclick="addPost('<?php echo $username; ?>');">Post</div>
                    <input type="hidden" name="wallowner" value="<?php echo $username; ?>" />
                    </td>
                </tr>
                </table>
			</form>
			<?php
			}
			?>
            <div id="listpost">
			<?php
				require_once 'php/viewer/wall_onepost.php';
				getNPost($username,0,3);
			?>           
			</div>
            <?php
        	$npost = mysql_num_rows(user::getAllPost($username));
			if ($npost>3){
            ?>
                <br style="clear:both"/>
                <a id="morePost" href="javascript:void()" onClick="getNPost('<?php echo $username; ?>', 3,3)" style="color:#FFF;margin:15px 0px;display:block">See More Post</a>
            <?php } ?>
            </div>
		<?php 
		}
		else
			echo 'User tidak/belum tersedia, silahkan cari yang lain.';
	?>
	</div></div>
	
	<div id="footerwrapper">
    	<div id="footer">
            <div id="footerleft"><br/>
            	ft, ft logoes are trademark of ft company. <br/>
            	Copyright 2010 by : <br/>
                13508011 - M. Albadr Lutan Nasution <br/>
                13508019 - Gregorius Ronny Kaluge <br/>
                13508099 - Alwi Alfiansyah Ramdan <br/>
            </div>
            <div id="footermiddle">
            	
            </div>
            <div id="footerright">
            	
            </div>
        </div>
    </div>
</body>
</html>
